const mongoose = require('mongoose');

const notificationSettingSchema = mongoose.Schema(
  {
    systemNotifications: {
      systemUpdate: {
        type: Boolean,
        default: true,
      },
      securityAlert: {
        type: Boolean,
        default: true,
      },
      backupResult: {
        type: Boolean,
        default: true,
      },
    },
    businessNotifications: {
      newUserRegistration: {
        type: Boolean,
        default: true,
      },
      foodSubmission: {
        type: Boolean,
        default: true,
      },
      recipePublication: {
        type: Boolean,
        default: true,
      },
      userFeedback: {
        type: Boolean,
        default: true,
      },
    },
    notificationMethods: {
      inApp: {
        type: Boolean,
        default: true,
      },
      email: {
        type: Boolean,
        default: true,
      },
      sms: {
        type: Boolean,
        default: false,
      },
      wechat: {
        type: Boolean,
        default: false,
      },
    },
    adminEmail: {
      type: String,
      required: true,
      trim: true,
    },
    priorityLevel: {
      type: String,
      enum: ['realtime', 'daily', 'weekly'],
      default: 'realtime',
    },
    isDeleted: {
      type: Boolean,
      default: false,
    },
  },
  {
    timestamps: true,
  }
);

/**
 * @typedef NotificationSetting
 */
const NotificationSetting = mongoose.model('NotificationSetting', notificationSettingSchema, 'notification_settings');

module.exports = NotificationSetting; 